package io.renren.modules.mvs.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.modules.mvs.dao.MvsViolationTypeDao;
import io.renren.modules.mvs.entity.ViolationTypeEntity;
import io.renren.modules.mvs.service.ViolationTypeService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


@Service
public class ViolationTypeServiceImpl extends ServiceImpl<MvsViolationTypeDao, ViolationTypeEntity> implements ViolationTypeService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        String key = (String) params.get("key");
        IPage<ViolationTypeEntity> page = this.page(
                new Query<ViolationTypeEntity>().getPage(params),
                new QueryWrapper<ViolationTypeEntity>().lambda()
                        .like(ViolationTypeEntity::getViolationTypeName, key)
                        .orderByAsc(ViolationTypeEntity::getSortValue)
        );

        return new PageUtils(page);
    }

    @Override
    public List<ViolationTypeEntity> getViolationTypeNameList() {
        return lambdaQuery().list();
    }

}